//
//  SEDoctorListCell.swift
//  SmartEyeForPatient
//
//  Created by QDSG on 2021/4/6.
//

import UIKit

class SEDoctorListCell: UITableViewCell {
    
    func update(with viewModel: SEDoctorDetailViewModel) {
        avatarView.kf.setAvatarImage(urlString: viewModel.model.imgPath,
                                     placeholder: viewModel.avatarPlaceholder)
        nameLabel.text = viewModel.model.name
        jobTitleLabel.text = viewModel.jobTitleAndDepartment
        hospitalLabel.text = viewModel.model.hospitalName
        goodAtLabel.text = viewModel.specialityDescribe
        viewModel.setOnlineStatusLabel(statusLabel)
        
        numberLabel.text = viewModel.inquiryCount
        numberLabelWidthConstraint.constant = viewModel.inquiryCountLabelWidth(numberLabel)
    }
    
    @IBOutlet private var numberLabelWidthConstraint: NSLayoutConstraint!
    
    @IBOutlet private weak var avatarView: UIImageView!
    @IBOutlet private weak var nameLabel: UILabel!
    @IBOutlet private weak var jobTitleLabel: UILabel!
    @IBOutlet private weak var hospitalLabel: UILabel!
    @IBOutlet private weak var numberLabel: UILabel! {
        didSet {
            numberLabel.layer.cornerRadius = numberLabel.height / 2
            numberLabel.layer.masksToBounds = true
        }
    }
    @IBOutlet private weak var goodAtLabel: UILabel!
    @IBOutlet private weak var statusLabel: UILabel!
    
}
